incremental links adding to uri

incremental links adding to uri

am 16.11.2007 22:11:36 von mtuller

I have links that display dates, incremented from one value up to
another. When I click on each link though, it adds the value to the
url. This is a snippet of the code:

for ($i=$first_year; $i<=$last_year; $i++)
{
echo ''.$first_yea r.' td>';
$first_year++;
}

The first time the link will be correct, then the second time it will
add ?year=2008 or whatever the value it to the uri. How can I make it
so that it doesn't keep adding to it, but replaces it?

Re: incremental links adding to uri

am 16.11.2007 22:26:39 von zeldorblat

On Nov 16, 4:11 pm, mtuller wrote:
> I have links that display dates, incremented from one value up to
> another. When I click on each link though, it adds the value to the
> url. This is a snippet of the code:
>
> for ($i=$first_year; $i<=$last_year; $i++)
> {
> echo ''.$first_yea r.' > td>';
> $first_year++;
>
> }
>
> The first time the link will be correct, then the second time it will
> add ?year=2008 or whatever the value it to the uri. How can I make it
> so that it doesn't keep adding to it, but replaces it?

Do you really have a reason to include $_SERVER['REQUEST_URI'] in the
link URL? In other words, are there parameters besides "year" that
you need to keep? If not, getting rid of $_SERVER['REQUEST_URI'] will
solve your problem.

Re: incremental links adding to uri

am 16.11.2007 22:51:55 von mtuller

On Nov 16, 3:26 pm, ZeldorBlat wrote:
> On Nov 16, 4:11 pm, mtuller wrote:
>
>
>
> > I have links that display dates, incremented from one value up to
> > another. When I click on each link though, it adds the value to the
> > url. This is a snippet of the code:
>
> > for ($i=$first_year; $i<=$last_year; $i++)
> > {
> > echo ''.$first_yea r.' > > td>';
> > $first_year++;
>
> > }
>
> > The first time the link will be correct, then the second time it will
> > add ?year=2008 or whatever the value it to the uri. How can I make it
> > so that it doesn't keep adding to it, but replaces it?
>
> Do you really have a reason to include $_SERVER['REQUEST_URI'] in the
> link URL? In other words, are there parameters besides "year" that
> you need to keep? If not, getting rid of $_SERVER['REQUEST_URI'] will
> solve your problem.

Yes, because this code is in a function that is used in multiple pages.

Re: incremental links adding to uri

am 17.11.2007 00:50:45 von mtuller

On Nov 16, 3:51 pm, mtuller wrote:
> On Nov 16, 3:26 pm, ZeldorBlat wrote:
>
>
>
> > On Nov 16, 4:11 pm, mtuller wrote:
>
> > > I have links that display dates, incremented from one value up to
> > > another. When I click on each link though, it adds the value to the
> > > url. This is a snippet of the code:
>
> > > for ($i=$first_year; $i<=$last_year; $i++)
> > > {
> > > echo ''.$first_yea r.' > > > td>';
> > > $first_year++;
>
> > > }
>
> > > The first time the link will be correct, then the second time it will
> > > add ?year=2008 or whatever the value it to the uri. How can I make it
> > > so that it doesn't keep adding to it, but replaces it?
>
> > Do you really have a reason to include $_SERVER['REQUEST_URI'] in the
> > link URL? In other words, are there parameters besides "year" that
> > you need to keep? If not, getting rid of $_SERVER['REQUEST_URI'] will
> > solve your problem.
>
> Yes, because this code is in a function that is used in multiple pages.

I was mistaken. I didn't need the $_SERVER['REQUEST_URI']. Thanks.